<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge ">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        const obj = {
            a: 0
        }

        for (let key in obj) {
            // 依次给对象设置拦截
            defineReactive(obj, key, obj[key]);
        }
        function defineReactive(obj, key, val) {
            Object.defineProperty(obj, key, {
                get() {
                    return ++val
                },

                set(value) {
                    val = value
                }
            })
        }

        if (obj.a == 1 && obj.a == 2 && obj.a == 3) {
            console.log('Win')
        }

    </script>

</body>

</html>